Dim instance As NinjaDbPro Dim value As T Dim value As T value = instance.Save(Of T)(value)
Parameters
- value
Type Parameters
- T
Return Value
The object populated with the primary key.
Dim instance As NinjaDbPro Dim value As T Dim value As T value = instance.Save(Of T)(value)
NinjaDbPro db = new NinjaDbPro("MyDatabaseDirectory", "MyDatabaseName"); //Licensed Mode //db.UserName = "John Smith 101224"; //db.LicenseKey = "aousdf832jasf=="; //Set before OpenDatabase. Default storage is IsolatedStorageDatabase. Other options are: //db.Storage = new MemoryDatabase(); //In memory database //db.Storage = new FileDatabase(); Order order = new Order(); order.Buyer = new Person(); order.Buyer.Name = "John Doe"; order.Buyer.DateCreated = DateTime.Now; order.OrderDetails = new List<OrderDetail>(); OrderDetail detail1 = new OrderDetail(); detail1.Item = new Product(); detail1.Item.Name = "Wizard"; detail1.Item.Cost = 29.98M; detail1.Quantity = 2; detail1.Order = order; order.OrderDetails.Add(detail1); OrderDetail detail2 = new OrderDetail(); detail2.Item = new Product(); detail2.Item.Name = ".NET Caching Library"; detail2.Item.Cost = 199.95M; detail2.Quantity = 1; detail2.Order = order; order.OrderDetails.Add(detail2); db.OpenDatabase(); //Everything will be saved to the database. //Child and parent objects can be saved seperately by setting up relationships as attributes. //This is wrapped in an implicit transaction, if any record fails it will all roll back db.Save(order); //Reload the entire tree Order orderCopy = db.Load<Order>(order.OrderId); //Get just a single object Person personCopy = db.Load<Person>(order.Buyer.PersonId); db.CloseDatabase();
Dim db As New NinjaDbPro("MyDatabaseDirectory", "MyDatabaseName") 'Licensed Mode 'db.UserName = "John Smith 101224"; 'db.LicenseKey = "aousdf832jasf=="; 'Set before OpenDatabase. Default storage is IsolatedStorageDatabase. Other options are: 'db.Storage = new MemoryDatabase(); //In memory database 'db.Storage = new FileDatabase(); Dim order As New Order() order.Buyer = New Person() order.Buyer.Name = "John Doe" order.Buyer.DateCreated = Date.Now order.OrderDetails = New List(Of OrderDetail)() Dim detail1 As New OrderDetail() detail1.Item = New Product() detail1.Item.Name = "Wizard" detail1.Item.Cost = 29.98D detail1.Quantity = 2 detail1.Order = order order.OrderDetails.Add(detail1) Dim detail2 As New OrderDetail() detail2.Item = New Product() detail2.Item.Name = ".NET Caching Library" detail2.Item.Cost = 199.95D detail2.Quantity = 1 detail2.Order = order order.OrderDetails.Add(detail2) db.OpenDatabase() 'Everything will be saved to the database. 'Child and parent objects can be saved seperately by setting up relationships as attributes. 'This is wrapped in an implicit transaction, if any record fails it will all roll back db.Save(order) 'Reload the entire tree Dim orderCopy As Order = db.Load(Of Order)(order.OrderId) 'Get just a single object Dim personCopy As Person = db.Load(Of Person)(order.Buyer.PersonId) db.CloseDatabase()
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2